home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_emacs.idb / usr / freeware / info / emacs-20.z / emacs-20
Encoding:
GNU Info File  |  1998-10-28  |  46.7 KB  |  1,111 lines

  1. This is Info file ../info/emacs, produced by Makeinfo-1.63 from the
  2. input file emacs.texi.
  3.  
  4. 
  5. File: emacs,  Node: Basic Kbd Macro,  Next: Save Kbd Macro,  Up: Keyboard Macros
  6.  
  7. Basic Use
  8. ---------
  9.  
  10.    To start defining a keyboard macro, type the `C-x (' command
  11. (`start-kbd-macro').  From then on, your keys continue to be executed,
  12. but also become part of the definition of the macro.  `Def' appears in
  13. the mode line to remind you of what is going on.  When you are
  14. finished, the `C-x )' command (`end-kbd-macro') terminates the
  15. definition (without becoming part of it!).  For example,
  16.  
  17.      C-x ( M-f foo C-x )
  18.  
  19. defines a macro to move forward a word and then insert `foo'.
  20.  
  21.    The macro thus defined can be invoked again with the `C-x e' command
  22. (`call-last-kbd-macro'), which may be given a repeat count as a numeric
  23. argument to execute the macro many times.  `C-x )' can also be given a
  24. repeat count as an argument, in which case it repeats the macro that
  25. many times right after defining it, but defining the macro counts as
  26. the first repetition (since it is executed as you define it).
  27. Therefore, giving `C-x )' an argument of 4 executes the macro
  28. immediately 3 additional times.  An argument of zero to `C-x e' or `C-x
  29. )' means repeat the macro indefinitely (until it gets an error or you
  30. type `C-g').
  31.  
  32.    If you wish to repeat an operation at regularly spaced places in the
  33. text, define a macro and include as part of the macro the commands to
  34. move to the next place you want to use it.  For example, if you want to
  35. change each line, you should position point at the start of a line, and
  36. define a macro to change that line and leave point at the start of the
  37. next line.  Then repeating the macro will operate on successive lines.
  38.  
  39.    After you have terminated the definition of a keyboard macro, you
  40. can add to the end of its definition by typing `C-u C-x ('.  This is
  41. equivalent to plain `C-x (' followed by retyping the whole definition
  42. so far.  As a consequence it re-executes the macro as previously
  43. defined.
  44.  
  45.    You can use function keys in a keyboard macro, just like keyboard
  46. keys.  You can even use mouse events, but be careful about that: when
  47. the macro replays the mouse event, it uses the original mouse position
  48. of that event, the position that the mouse had while you were defining
  49. the macro.  The effect of this may be hard to predict.  (Using the
  50. current mouse position would be even less predictable.)
  51.  
  52.    One thing that doesn't always work well in a keyboard macro is the
  53. command `C-M-c' (`exit-recursive-edit').  When this command exits a
  54. recursive edit that started within the macro, it works as you'd expect.
  55. But if it exits a recursive edit that started before you invoked the
  56. keyboard macro, it also necessarily exits the keyboard macro as part of
  57. the process.
  58.  
  59.    You can edit a keyboard macro already defined by typing `C-x C-k'
  60. (`edit-kbd-macro').  Follow that with the keyboard input that you would
  61. use to invoke the macro--`C-x e' or `M-x NAME' or some other key
  62. sequence.  This formats the macro definition in a buffer and enters a
  63. specialized major mode for editing it.  Type `C-h m' once in that
  64. buffer to display details of how to edit the macro.  When you are
  65. finished editing, type `C-c C-c'.
  66.  
  67.    The command `M-x apply-macro-to-region-lines' repeats the last
  68. defined keyboard macro on each complete line within the current region.
  69. It does this line by line, by moving point to the beginning of the line
  70. and then executing the macro.
  71.  
  72. 
  73. File: emacs,  Node: Save Kbd Macro,  Next: Kbd Macro Query,  Prev: Basic Kbd Macro,  Up: Keyboard Macros
  74.  
  75. Naming and Saving Keyboard Macros
  76. ---------------------------------
  77.  
  78.    If you wish to save a keyboard macro for longer than until you
  79. define the next one, you must give it a name using `M-x
  80. name-last-kbd-macro'.  This reads a name as an argument using the
  81. minibuffer and defines that name to execute the macro.  The macro name
  82. is a Lisp symbol, and defining it in this way makes it a valid command
  83. name for calling with `M-x' or for binding a key to with
  84. `global-set-key' (*note Keymaps::.).  If you specify a name that has a
  85. prior definition other than another keyboard macro, an error message is
  86. printed and nothing is changed.
  87.  
  88.    Once a macro has a command name, you can save its definition in a
  89. file.  Then it can be used in another editing session.  First, visit
  90. the file you want to save the definition in.  Then use this command:
  91.  
  92.      M-x insert-kbd-macro RET MACRONAME RET
  93.  
  94. This inserts some Lisp code that, when executed later, will define the
  95. same macro with the same definition it has now.  (You need not
  96. understand Lisp code to do this, because `insert-kbd-macro' writes the
  97. Lisp code for you.)  Then save the file.  You can load the file later
  98. with `load-file' (*note Lisp Libraries::.).  If the file you save in is
  99. your init file `~/.emacs' (*note Init File::.) then the macro will be
  100. defined each time you run Emacs.
  101.  
  102.    If you give `insert-kbd-macro' a numeric argument, it makes
  103. additional Lisp code to record the keys (if any) that you have bound to
  104. the keyboard macro, so that the macro will be reassigned the same keys
  105. when you load the file.
  106.  
  107. 
  108. File: emacs,  Node: Kbd Macro Query,  Prev: Save Kbd Macro,  Up: Keyboard Macros
  109.  
  110. Executing Macros with Variations
  111. --------------------------------
  112.  
  113.    Using `C-x q' (`kbd-macro-query'), you can get an effect similar to
  114. that of `query-replace', where the macro asks you each time around
  115. whether to make a change.  While defining the macro, type `C-x q' at
  116. the point where you want the query to occur.  During macro definition,
  117. the `C-x q' does nothing, but when you run the macro later, `C-x q'
  118. asks you interactively whether to continue.
  119.  
  120.    The valid responses when `C-x q' asks are SPC (or `y'), DEL (or
  121. `n'), RET (or `q'), `C-l' and `C-r'.  The answers are the same as in
  122. `query-replace', though not all of the `query-replace' options are
  123. meaningful.
  124.  
  125.    These responses include SPC to continue, and DEL to skip the
  126. remainder of this repetition of the macro and start right away with the
  127. next repetition.  RET means to skip the remainder of this repetition
  128. and cancel further repetitions.  `C-l' redraws the screen and asks you
  129. again for a character to say what to do.
  130.  
  131.    `C-r' enters a recursive editing level, in which you can perform
  132. editing which is not part of the macro.  When you exit the recursive
  133. edit using `C-M-c', you are asked again how to continue with the
  134. keyboard macro.  If you type a SPC at this time, the rest of the macro
  135. definition is executed.  It is up to you to leave point and the text in
  136. a state such that the rest of the macro will do what you want.
  137.  
  138.    `C-u C-x q', which is `C-x q' with a numeric argument, performs a
  139. completely different function.  It enters a recursive edit reading
  140. input from the keyboard, both when you type it during the definition of
  141. the macro, and when it is executed from the macro.  During definition,
  142. the editing you do inside the recursive edit does not become part of
  143. the macro.  During macro execution, the recursive edit gives you a
  144. chance to do some particularized editing on each repetition.  *Note
  145. Recursive Edit::.
  146.  
  147. 
  148. File: emacs,  Node: Key Bindings,  Next: Keyboard Translations,  Prev: Keyboard Macros,  Up: Customization
  149.  
  150. Customizing Key Bindings
  151. ========================
  152.  
  153.    This section describes "key bindings" which map keys to commands,
  154. and the "keymaps" which record key bindings.  It also explains how to
  155. customize key bindings.
  156.  
  157.    Recall that a command is a Lisp function whose definition provides
  158. for interactive use.  Like every Lisp function, a command has a function
  159. name which usually consists of lower case letters and hyphens.
  160.  
  161. * Menu:
  162.  
  163. * Keymaps::          Generalities.  The global keymap.
  164. * Prefix Keymaps::   Keymaps for prefix keys.
  165. * Local Keymaps::    Major and minor modes have their own keymaps.
  166. * Minibuffer Maps::  The minibuffer uses its own local keymaps.
  167. * Rebinding::        How to redefine one key's meaning conveniently.
  168. * Init Rebinding::   Rebinding keys with your init file, `.emacs'.
  169. * Function Keys::    Rebinding terminal function keys.
  170. * Named ASCII Chars::Distinguishing TAB from `C-i', and so on.
  171. * Mouse Buttons::    Rebinding mouse buttons in Emacs.
  172. * Disabling::        Disabling a command means confirmation is required
  173.                        before it can be executed.  This is done to protect
  174.                        beginners from surprises.
  175.  
  176. 
  177. File: emacs,  Node: Keymaps,  Next: Prefix Keymaps,  Up: Key Bindings
  178.  
  179. Keymaps
  180. -------
  181.  
  182.    The bindings between key sequences and command functions are recorded
  183. in data structures called "keymaps".  Emacs has many of these, each
  184. used on particular occasions.
  185.  
  186.    Recall that a "key sequence" ("key", for short) is a sequence of
  187. "input events" that have a meaning as a unit.  Input events include
  188. characters, function keys and mouse buttons--all the inputs that you
  189. can send to the computer with your terminal.  A key sequence gets its
  190. meaning from its "binding", which says what command it runs.  The
  191. function of keymaps is to record these bindings.
  192.  
  193.    The "global" keymap is the most important keymap because it is
  194. always in effect.  The global keymap defines keys for Fundamental mode;
  195. most of these definitions are common to most or all major modes.  Each
  196. major or minor mode can have its own keymap which overrides the global
  197. definitions of some keys.
  198.  
  199.    For example, a self-inserting character such as `g' is
  200. self-inserting because the global keymap binds it to the command
  201. `self-insert-command'.  The standard Emacs editing characters such as
  202. `C-a' also get their standard meanings from the global keymap.
  203. Commands to rebind keys, such as `M-x global-set-key', actually work by
  204. storing the new binding in the proper place in the global map.  *Note
  205. Rebinding::.
  206.  
  207.    Meta characters work differently; Emacs translates each Meta
  208. character into a pair of characters starting with ESC.  When you type
  209. the character `M-a' in a key sequence, Emacs replaces it with `ESC a'.
  210. A meta key comes in as a single input event, but becomes two events for
  211. purposes of key bindings.  The reason for this is historical, and we
  212. might change it someday.
  213.  
  214.    Most modern keyboards have function keys as well as character keys.
  215. Function keys send input events just as character keys do, and keymaps
  216. can have bindings for them.
  217.  
  218.    On many terminals, typing a function key actually sends the computer
  219. a sequence of characters; the precise details of the sequence depends on
  220. which function key and on the model of terminal you are using.  (Often
  221. the sequence starts with `ESC ['.)  If Emacs understands your terminal
  222. type properly, it recognizes the character sequences forming function
  223. keys wherever they occur in a key sequence (not just at the beginning).
  224. Thus, for most purposes, you can pretend the function keys reach Emacs
  225. directly and ignore their encoding as character sequences.
  226.  
  227.    Mouse buttons also produce input events.  These events come with
  228. other data--the window and position where you pressed or released the
  229. button, and a time stamp.  But only the choice of button matters for key
  230. bindings; the other data matters only if a command looks at it.
  231. (Commands designed for mouse invocation usually do look at the other
  232. data.)
  233.  
  234.    A keymap records definitions for single events.  Interpreting a key
  235. sequence of multiple events involves a chain of keymaps.  The first
  236. keymap gives a definition for the first event; this definition is
  237. another keymap, which is used to look up the second event in the
  238. sequence, and so on.
  239.  
  240.    Key sequences can mix function keys and characters.  For example,
  241. `C-x SELECT' makes sense.  If you make SELECT a prefix key, then
  242. `SELECT C-n' makes sense.  You can even mix mouse events with keyboard
  243. events, but we recommend against it, because such sequences are
  244. inconvenient to type in.
  245.  
  246.    As a user, you can redefine any key; but it might be best to stick to
  247. key sequences that consist of `C-c' followed by a letter.  These keys
  248. are "reserved for users,", so they won't conflict with any properly
  249. designed Emacs extension.  If you redefine some other key, your
  250. definition may be overridden by certain extensions or major modes which
  251. redefine the same key.
  252.  
  253. 
  254. File: emacs,  Node: Prefix Keymaps,  Next: Local Keymaps,  Prev: Keymaps,  Up: Key Bindings
  255.  
  256. Prefix Keymaps
  257. --------------
  258.  
  259.    A prefix key such as `C-x' or ESC has its own keymap, which holds
  260. the definition for the event that immediately follows that prefix.
  261.  
  262.    The definition of a prefix key is usually the keymap to use for
  263. looking up the following event.  The definition can also be a Lisp
  264. symbol whose function definition is the following keymap; the effect is
  265. the same, but it provides a command name for the prefix key that can be
  266. used as a description of what the prefix key is for.  Thus, the binding
  267. of `C-x' is the symbol `Ctl-X-Prefix', whose function definition is the
  268. keymap for `C-x' commands.  The definitions of `C-c', `C-x', `C-h' and
  269. ESC as prefix keys appear in the global map, so these prefix keys are
  270. always available.
  271.  
  272.    Aside from ordinary prefix keys, there is a fictitious "prefix key"
  273. which represents the menu bar; see *Note Menu Bar: (elisp)Menu Bar, for
  274. special information about menu bar key bindings.  Mouse button events
  275. that invoke pop-up menus are also prefix keys; see *Note Menu Keymaps:
  276. (elisp)Menu Keymaps, for more details.
  277.  
  278.    Some prefix keymaps are stored in variables with names:
  279.  
  280.    * `ctl-x-map' is the variable name for the map used for characters
  281.      that follow `C-x'.
  282.  
  283.    * `help-map' is for characters that follow `C-h'.
  284.  
  285.    * `esc-map' is for characters that follow ESC.  Thus, all Meta
  286.      characters are actually defined by this map.
  287.  
  288.    * `ctl-x-4-map' is for characters that follow `C-x 4'.
  289.  
  290.    * `mode-specific-map' is for characters that follow `C-c'.
  291.  
  292. 
  293. File: emacs,  Node: Local Keymaps,  Next: Minibuffer Maps,  Prev: Prefix Keymaps,  Up: Key Bindings
  294.  
  295. Local Keymaps
  296. -------------
  297.  
  298.    So far we have explained the ins and outs of the global map.  Major
  299. modes customize Emacs by providing their own key bindings in "local
  300. keymaps".  For example, C mode overrides TAB to make it indent the
  301. current line for C code.  Portions of text in the buffer can specify
  302. their own keymaps to substitute for the keymap of the buffer's major
  303. mode.
  304.  
  305.    Minor modes can also have local keymaps.  Whenever a minor mode is
  306. in effect, the definitions in its keymap override both the major mode's
  307. local keymap and the global keymap.
  308.  
  309.    The local keymaps for Lisp mode and several other major modes always
  310. exist even when not in use.  These are kept in variables named
  311. `lisp-mode-map' and so on.  For major modes less often used, the local
  312. keymap is normally constructed only when the mode is used for the first
  313. time in a session.  This is to save space.  If you wish to change one
  314. of these keymaps, you must use the major mode's "mode hook"--see below.
  315.  
  316.    All minor mode keymaps are created in advance.  There is no way to
  317. defer their creation until the first time the minor mode is enabled.
  318.  
  319.    A local keymap can locally redefine a key as a prefix key by defining
  320. it as a prefix keymap.  If the key is also defined globally as a prefix,
  321. then its local and global definitions (both keymaps) effectively
  322. combine: both of them are used to look up the event that follows the
  323. prefix key.  Thus, if the mode's local keymap defines `C-c' as another
  324. keymap, and that keymap defines `C-z' as a command, this provides a
  325. local meaning for `C-c C-z'.  This does not affect other sequences that
  326. start with `C-c'; if those sequences don't have their own local
  327. bindings, their global bindings remain in effect.
  328.  
  329.    Another way to think of this is that Emacs handles a multi-event key
  330. sequence by looking in several keymaps, one by one, for a binding of the
  331. whole key sequence.  First it checks the minor mode keymaps for minor
  332. modes that are enabled, then it checks the major mode's keymap, and then
  333. it checks the global keymap.  This is not precisely how key lookup
  334. works, but it's good enough for understanding ordinary circumstances.
  335.  
  336.    To change the local bindings of a major mode, you must change the
  337. mode's local keymap.  Normally you must wait until the first time the
  338. mode is used, because most major modes don't create their keymaps until
  339. then.  If you want to specify something in your `~/.emacs' file to
  340. change a major mode's bindings, you must use the mode's mode hook to
  341. delay the change until the mode is first used.
  342.  
  343.    For example, the command `texinfo-mode' to select Texinfo mode runs
  344. the hook `texinfo-mode-hook'.  Here's how you can use the hook to add
  345. local bindings (not very useful, we admit) for `C-c n' and `C-c p' in
  346. Texinfo mode:
  347.  
  348.      (add-hook 'texinfo-mode-hook
  349.                '(lambda ()
  350.                   (define-key texinfo-mode-map
  351.                               "\C-cp"
  352.                               'backward-paragraph)
  353.                   (define-key texinfo-mode-map
  354.                               "\C-cn"
  355.                               'forward-paragraph)
  356.                   ))
  357.  
  358.    *Note Hooks::.
  359.  
  360. 
  361. File: emacs,  Node: Minibuffer Maps,  Next: Rebinding,  Prev: Local Keymaps,  Up: Key Bindings
  362.  
  363. Minibuffer Keymaps
  364. ------------------
  365.  
  366.    The minibuffer has its own set of local keymaps; they contain various
  367. completion and exit commands.
  368.  
  369.    * `minibuffer-local-map' is used for ordinary input (no completion).
  370.  
  371.    * `minibuffer-local-ns-map' is similar, except that SPC exits just
  372.      like RET.  This is used mainly for Mocklisp compatibility.
  373.  
  374.    * `minibuffer-local-completion-map' is for permissive completion.
  375.  
  376.    * `minibuffer-local-must-match-map' is for strict completion and for
  377.      cautious completion.
  378.  
  379. 
  380. File: emacs,  Node: Rebinding,  Next: Init Rebinding,  Prev: Minibuffer Maps,  Up: Key Bindings
  381.  
  382. Changing Key Bindings Interactively
  383. -----------------------------------
  384.  
  385.    The way to redefine an Emacs key is to change its entry in a keymap.
  386. You can change the global keymap, in which case the change is effective
  387. in all major modes (except those that have their own overriding local
  388. definitions for the same key).  Or you can change the current buffer's
  389. local map, which affects all buffers using the same major mode.
  390.  
  391. `M-x global-set-key RET KEY CMD RET'
  392.      Define KEY globally to run CMD.
  393.  
  394. `M-x local-set-key RET KEY CMD RET'
  395.      Define KEY locally (in the major mode now in effect) to run CMD.
  396.  
  397. `M-x global-unset-key RET KEY'
  398.      Make KEY undefined in the global map.
  399.  
  400. `M-x local-unset-key RET KEY'
  401.      Make KEY undefined locally (in the major mode now in effect).
  402.  
  403.    For example, suppose you like to execute commands in a subshell
  404. within an Emacs buffer, instead of suspending Emacs and executing
  405. commands in your login shell.  Normally, `C-z' is bound to the function
  406. `suspend-emacs' (when not using the X Window System), but you can
  407. change `C-z' to invoke an interactive subshell within Emacs, by binding
  408. it to `shell' as follows:
  409.  
  410.      M-x global-set-key RET C-z shell RET
  411.  
  412. `global-set-key' reads the command name after the key.   After you
  413. press the key, a message like this appears so that you can confirm that
  414. you are binding the key you want:
  415.  
  416.      Set key C-z to command:
  417.  
  418.    You can redefine function keys and mouse events in the same way; just
  419. type the function key or click the mouse when it's time to specify the
  420. key to rebind.
  421.  
  422.    You can rebind a key that contains more than one event in the same
  423. way.  Emacs keeps reading the key to rebind until it is a complete key
  424. (that is, not a prefix key).  Thus, if you type `C-f' for KEY, that's
  425. the end; the minibuffer is entered immediately to read CMD.  But if you
  426. type `C-x', another character is read; if that is `4', another
  427. character is read, and so on.  For example,
  428.  
  429.      M-x global-set-key RET C-x 4 $ spell-other-window RET
  430.  
  431. redefines `C-x 4 $' to run the (fictitious) command
  432. `spell-other-window'.
  433.  
  434.    The two-character keys consisting of `C-c' followed by a letter are
  435. reserved for user customizations.  Lisp programs are not supposed to
  436. define these keys, so the bindings you make for them will be available
  437. in all major modes and will never get in the way of anything.
  438.  
  439.    You can remove the global definition of a key with
  440. `global-unset-key'.  This makes the key "undefined"; if you type it,
  441. Emacs will just beep.  Similarly, `local-unset-key' makes a key
  442. undefined in the current major mode keymap, which makes the global
  443. definition (or lack of one) come back into effect in that major mode.
  444.  
  445.    If you have redefined (or undefined) a key and you subsequently wish
  446. to retract the change, undefining the key will not do the job--you need
  447. to redefine the key with its standard definition.  To find the name of
  448. the standard definition of a key, go to a Fundamental mode buffer and
  449. use `C-h c'.  The documentation of keys in this manual also lists their
  450. command names.
  451.  
  452.    If you want to prevent yourself from invoking a command by mistake,
  453. it is better to disable the command than to undefine the key.  A
  454. disabled command is less work to invoke when you really want to.  *Note
  455. Disabling::.
  456.  
  457. 
  458. File: emacs,  Node: Init Rebinding,  Next: Function Keys,  Prev: Rebinding,  Up: Key Bindings
  459.  
  460. Rebinding Keys in Your Init File
  461. --------------------------------
  462.  
  463.    If you have a set of key bindings that you like to use all the time,
  464. you can specify them in your `.emacs' file by using their Lisp syntax.
  465.  
  466.    The simplest method for doing this works for ASCII characters and
  467. Meta-modified ASCII characters only.  This method uses a string to
  468. represent the key sequence you want to rebind.  For example, here's how
  469. to bind `C-z' to `shell':
  470.  
  471.      (global-set-key "\C-z" 'shell)
  472.  
  473. This example uses a string constant containing one character, `C-z'.
  474. The single-quote before the command name, `shell', marks it as a
  475. constant symbol rather than a variable.  If you omit the quote, Emacs
  476. would try to evaluate `shell' immediately as a variable.  This probably
  477. causes an error; it certainly isn't what you want.
  478.  
  479.    Here is another example that binds a key sequence two characters
  480. long:
  481.  
  482.      (global-set-key "\C-xl" 'make-symbolic-link)
  483.  
  484.    When the key sequence includes function keys or mouse button events,
  485. or non-ASCII characters such as `C-=' or `H-a', you must use the more
  486. general method of rebinding, which uses a vector to specify the key
  487. sequence.
  488.  
  489.    The way to write a vector in Emacs Lisp is with square brackets
  490. around the vector elements.  Use spaces to separate the elements.  If an
  491. element is a symbol, simply write the symbol's name--no other
  492. delimiters or punctuation are needed.  If a vector element is a
  493. character, write it as a Lisp character constant: `?' followed by the
  494. character as it would appear in a string.
  495.  
  496.    Here are examples of using vectors to rebind `C-=' (a control
  497. character outside of ASCII), `H-a' (a Hyper character; ASCII doesn't
  498. have Hyper at all); f7 (a function key), and `C-Mouse-1' (a
  499. keyboard-modified mouse button):
  500.  
  501.      (global-set-key [?\C-=] 'make-symbolic-link)
  502.      (global-set-key [?\H-a] 'make-symbolic-link)
  503.      (global-set-key [f7] 'make-symbolic-link)
  504.      (global-set-key [C-mouse-1] 'make-symbolic-link)
  505.  
  506.    You can use a vector for the simple cases too.  Here's how to rewrite
  507. the first two examples, above, to use vectors:
  508.  
  509.      (global-set-key [?\C-z] 'shell)
  510.      
  511.      (global-set-key [?\C-x ?l] 'make-symbolic-link)
  512.  
  513. 
  514. File: emacs,  Node: Function Keys,  Next: Named ASCII Chars,  Prev: Init Rebinding,  Up: Key Bindings
  515.  
  516. Rebinding Function Keys
  517. -----------------------
  518.  
  519.    Key sequences can contain function keys as well as ordinary
  520. characters.  Just as Lisp characters (actually integers) represent
  521. keyboard characters, Lisp symbols represent function keys.  If the
  522. function key has a word as its label, then that word is also the name of
  523. the corresponding Lisp symbol.  Here are the conventional Lisp names for
  524. common function keys:
  525.  
  526. `left', `up', `right', `down'
  527.      Cursor arrow keys.
  528.  
  529. `begin', `end', `home', `next', `prior'
  530.      Other cursor repositioning keys.
  531.  
  532. `select', `print', `execute', `backtab'
  533. `insert', `undo', `redo', `clearline'
  534. `insertline', `deleteline', `insertchar', `deletechar',
  535.      Miscellaneous function keys.
  536.  
  537. `f1', `f2', ... `f35'
  538.      Numbered function keys (across the top of the keyboard).
  539.  
  540. `kp-add', `kp-subtract', `kp-multiply', `kp-divide'
  541. `kp-backtab', `kp-space', `kp-tab', `kp-enter'
  542. `kp-separator', `kp-decimal', `kp-equal'
  543.      Keypad keys (to the right of the regular keyboard), with names or
  544.      punctuation.
  545.  
  546. `kp-0', `kp-1', ... `kp-9'
  547.      Keypad keys with digits.
  548.  
  549. `kp-f1', `kp-f2', `kp-f3', `kp-f4'
  550.      Keypad PF keys.
  551.  
  552.    These names are conventional, but some systems (especially when using
  553. X windows) may use different names.  To make certain what symbol is used
  554. for a given function key on your terminal, type `C-h c' followed by
  555. that key.
  556.  
  557.    A key sequence which contains function key symbols (or anything but
  558. ASCII characters) must be a vector rather than a string.  The vector
  559. syntax uses spaces between the elements, and square brackets around the
  560. whole vector.  Thus, to bind function key `f1' to the command `rmail',
  561. write the following:
  562.  
  563.      (global-set-key [f1] 'rmail)
  564.  
  565. To bind the right-arrow key to the command `forward-char', you can use
  566. this expression:
  567.  
  568.      (global-set-key [right] 'forward-char)
  569.  
  570. This uses the Lisp syntax for a vector containing the symbol `right'.
  571. (This binding is present in Emacs by default.)
  572.  
  573.    *Note Init Rebinding::, for more information about using vectors for
  574. rebinding.
  575.  
  576.    You can mix function keys and characters in a key sequence.  This
  577. example binds `C-x NEXT' to the command `forward-page'.
  578.  
  579.      (global-set-key [?\C-x next] 'forward-page)
  580.  
  581. where `?\C-x' is the Lisp character constant for the character `C-x'.
  582. The vector element `next' is a symbol and therefore does not take a
  583. question mark.
  584.  
  585.    You can use the modifier keys CTRL, META, HYPER, SUPER, ALT and
  586. SHIFT with function keys.  To represent these modifiers, add the
  587. strings `C-', `M-', `H-', `s-', `A-' and `S-' at the front of the
  588. symbol name.  Thus, here is how to make `Hyper-Meta-RIGHT' move forward
  589. a word:
  590.  
  591.      (global-set-key [H-M-right] 'forward-word)
  592.  
  593. 
  594. File: emacs,  Node: Named ASCII Chars,  Next: Mouse Buttons,  Prev: Function Keys,  Up: Key Bindings
  595.  
  596. Named ASCII Control Characters
  597. ------------------------------
  598.  
  599.    TAB, RET, BS, LFD, ESC and DEL started out as names for certain
  600. ASCII control characters, used so often that they have special keys of
  601. their own.  Later, users found it convenient to distinguish in Emacs
  602. between these keys and the "same" control characters typed with the
  603. CTRL key.
  604.  
  605.    Emacs 19 distinguishes these two kinds of input, when used with the X
  606. Window System.  It treats the "special" keys as function keys named
  607. `tab', `return', `backspace', `linefeed', `escape', and `delete'.
  608. These function keys translate automatically into the corresponding
  609. ASCII characters *if* they have no bindings of their own.  As a result,
  610. neither users nor Lisp programs need to pay attention to the
  611. distinction unless they care to.
  612.  
  613.    If you do not want to distinguish between (for example) TAB and
  614. `C-i', make just one binding, for the ASCII character TAB (octal code
  615. 011).  If you do want to distinguish, make one binding for this ASCII
  616. character, and another for the "function key" `tab'.
  617.  
  618.    With an ordinary ASCII terminal, there is no way to distinguish
  619. between TAB and `C-i' (and likewise for other such pairs), because the
  620. terminal sends the same character in both cases.
  621.  
  622. 
  623. File: emacs,  Node: Mouse Buttons,  Next: Disabling,  Prev: Named ASCII Chars,  Up: Key Bindings
  624.  
  625. Rebinding Mouse Buttons
  626. -----------------------
  627.  
  628.    Emacs uses Lisp symbols to designate mouse buttons, too.  The
  629. ordinary mouse events in Emacs are "click" events; these happen when you
  630. press a button and release it without moving the mouse.  You can also
  631. get "drag" events, when you move the mouse while holding the button
  632. down.  Drag events happen when you finally let go of the button.
  633.  
  634.    The symbols for basic click events are `mouse-1' for the leftmost
  635. button, `mouse-2' for the next, and so on.  Here is how you can
  636. redefine the second mouse button to split the current window:
  637.  
  638.      (global-set-key [mouse-2] 'split-window-vertically)
  639.  
  640.    The symbols for drag events are similar, but have the prefix `drag-'
  641. before the word `mouse'.  For example, dragging the first button
  642. generates a `drag-mouse-1' event.
  643.  
  644.    You can also define bindings for events that occur when a mouse
  645. button is pressed down.  These events start with `down-' instead of
  646. `drag-'.  Such events are generated only if they have key bindings.
  647. When you get a button-down event, a corresponding click or drag event
  648. will always follow.
  649.  
  650.    If you wish, you can distinguish single, double, and triple clicks.
  651. A double click means clicking a mouse button twice in approximately the
  652. same place.  The first click generates an ordinary click event.  The
  653. second click, if it comes soon enough, generates a double-click event
  654. instead.  The event type for a double click event starts with
  655. `double-': for example, `double-mouse-3'.
  656.  
  657.    This means that you can give a special meaning to the second click at
  658. the same place, but it must act on the assumption that the ordinary
  659. single click definition has run when the first click was received.
  660.  
  661.    This constrains what you can do with double clicks, but user
  662. interface designers say that this constraint ought to be followed in
  663. any case.  A double click should do something similar to the single
  664. click, only "more so".  The command for the double-click event should
  665. perform the extra work for the double click.
  666.  
  667.    If a double-click event has no binding, it changes to the
  668. corresponding single-click event.  Thus, if you don't define a
  669. particular double click specially, it executes the single-click command
  670. twice.
  671.  
  672.    Emacs also supports triple-click events whose names start with
  673. `triple-'.  Emacs does not distinguish quadruple clicks as event types;
  674. clicks beyond the third generate additional triple-click events.
  675. However, the full number of clicks is recorded in the event list, so you
  676. can distinguish if you really want to.  We don't recommend distinct
  677. meanings for more than three clicks, but sometimes it is useful for
  678. subsequent clicks to cycle through the same set of three meanings, so
  679. that four clicks are equivalent to one click, five are equivalent to
  680. two, and six are equivalent to three.
  681.  
  682.    Emacs also records multiple presses in drag and button-down events.
  683. For example, when you press a button twice, then move the mouse while
  684. holding the button, Emacs gets a `double-drag-' event.  And at the
  685. moment when you press it down for the second time, Emacs gets a
  686. `double-down-' event (which is ignored, like all button-down events, if
  687. it has no binding).
  688.  
  689.    The variable `double-click-time' specifies how long may elapse
  690. between clicks that are recognized as a pair.  Its value is measured in
  691. milliseconds.  If the value is `nil', double clicks are not detected at
  692. all.  If the value is `t', then there is no time limit.
  693.  
  694.    The symbols for mouse events also indicate the status of the modifier
  695. keys, with the usual prefixes `C-', `M-', `H-', `s-', `A-' and `S-'.
  696. These always precede `double-' or `triple-', which always precede
  697. `drag-' or `down-'.
  698.  
  699.    A frame includes areas that don't show text from the buffer, such as
  700. the mode line and the scroll bar.  You can tell whether a mouse button
  701. comes from a special area of the screen by means of dummy "prefix
  702. keys."  For example, if you click the mouse in the mode line, you get
  703. the prefix key `mode-line' before the ordinary mouse-button symbol.
  704. Thus, here is how to define the command for clicking the first button in
  705. a mode line to run `scroll-up':
  706.  
  707.      (global-set-key [mode-line mouse-1] 'scroll-up)
  708.  
  709.    Here is the complete list of these dummy prefix keys and their
  710. meanings:
  711.  
  712. `mode-line'
  713.      The mouse was in the mode line of a window.
  714.  
  715. `vertical-line'
  716.      The mouse was in the vertical line separating side-by-side
  717.      windows.  (If you use scroll bars, they appear in place of these
  718.      vertical lines.)
  719.  
  720. `vertical-scroll-bar'
  721.      The mouse was in a vertical scroll bar.  (This is the only kind of
  722.      scroll bar Emacs currently supports.)
  723.  
  724.    You can put more than one mouse button in a key sequence, but it
  725. isn't usual to do so.
  726.  
  727. 
  728. File: emacs,  Node: Disabling,  Prev: Mouse Buttons,  Up: Key Bindings
  729.  
  730. Disabling Commands
  731. ------------------
  732.  
  733.    Disabling a command marks the command as requiring confirmation
  734. before it can be executed.  The purpose of disabling a command is to
  735. prevent beginning users from executing it by accident and being
  736. confused.
  737.  
  738.    An attempt to invoke a disabled command interactively in Emacs
  739. displays a window containing the command's name, its documentation, and
  740. some instructions on what to do immediately; then Emacs asks for input
  741. saying whether to execute the command as requested, enable it and
  742. execute it, or cancel.  If you decide to enable the command, you are
  743. asked whether to do this permanently or just for the current session.
  744. Enabling permanently works by automatically editing your `.emacs' file.
  745.  
  746.    The direct mechanism for disabling a command is to put a non-`nil'
  747. `disabled' property on the Lisp symbol for the command.  Here is the
  748. Lisp program to do this:
  749.  
  750.      (put 'delete-region 'disabled t)
  751.  
  752.    If the value of the `disabled' property is a string, that string is
  753. included in the message printed when the command is used:
  754.  
  755.      (put 'delete-region 'disabled
  756.           "It's better to use `kill-region' instead.\n")
  757.  
  758.    You can make a command disabled either by editing the `.emacs' file
  759. directly or with the command `M-x disable-command', which edits the
  760. `.emacs' file for you.  Likewise, `M-x enable-command' edits `.emacs'
  761. to enable a command permanently.  *Note Init File::.
  762.  
  763.    Whether a command is disabled is independent of what key is used to
  764. invoke it; disabling also applies if the command is invoked using
  765. `M-x'.  Disabling a command has no effect on calling it as a function
  766. from Lisp programs.
  767.  
  768. 
  769. File: emacs,  Node: Keyboard Translations,  Next: Syntax,  Prev: Key Bindings,  Up: Customization
  770.  
  771. Keyboard Translations
  772. =====================
  773.  
  774.    Some keyboards do not make it convenient to send all the special
  775. characters that Emacs uses.  The most common problem case is the DEL
  776. character.  Some keyboards provide no convenient way to type this very
  777. important character--usually because they were designed to expect the
  778. character `C-h' to be used for deletion.  On these keyboard, if you
  779. press the key normally used for deletion, Emacs handles the `C-h' as a
  780. prefix character and offers you a list of help options, which is not
  781. what you want.
  782.  
  783.    You can work around this problem within Emacs by setting up keyboard
  784. translations to turn `C-h' into DEL and DEL into `C-h', as follows:
  785.  
  786.      ;; Translate `C-h' to DEL.
  787.      (keyboard-translate ?\C-h ?\C-?)
  788.      
  789.      ;; Translate DEL to `C-h'.
  790.      (keyboard-translate ?\C-? ?\C-h)
  791.  
  792.    Keyboard translations are not the same as key bindings in keymaps
  793. (*note Keymaps::.).  Emacs contains numerous keymaps that apply in
  794. different situations, but there is only one set of keyboard
  795. translations, and it applies to every character that Emacs reads from
  796. the terminal.  Keyboard translations take place at the lowest level of
  797. input processing; the keys that are looked up in keymaps contain the
  798. characters that result from keyboard translation.
  799.  
  800.    Under X, the keyboard key named DELETE is a function key and is
  801. distinct from the ASCII character named DEL.  *Note Named ASCII
  802. Chars::.  Keyboard translations affect only ASCII character input, not
  803. function keys; thus, the above example used under X does not affect the
  804. DELETE key.  However, the translation above isn't necessary under X,
  805. because Emacs can also distinguish between the BACKSPACE key and `C-h';
  806. and it normally treats BACKSPACE as DEL.
  807.  
  808.    For full information about how to use keyboard translations, see
  809. *Note Translating Input: (elisp)Translating Input.
  810.  
  811. 
  812. File: emacs,  Node: Syntax,  Next: Init File,  Prev: Keyboard Translations,  Up: Customization
  813.  
  814. The Syntax Table
  815. ================
  816.  
  817.    All the Emacs commands which parse words or balance parentheses are
  818. controlled by the "syntax table".  The syntax table says which
  819. characters are opening delimiters, which are parts of words, which are
  820. string quotes, and so on.  Each major mode has its own syntax table
  821. (though sometimes related major modes use the same one) which it
  822. installs in each buffer that uses that major mode.  The syntax table
  823. installed in the current buffer is the one that all commands use, so we
  824. call it "the" syntax table.  A syntax table is a Lisp object, a vector
  825. of length 256 whose elements are numbers.
  826.  
  827.    To display a description of the contents of the current syntax table,
  828. type `C-h s' (`describe-syntax').  The description of each character
  829. includes both the string you would have to give to
  830. `modify-syntax-entry' to set up that character's current syntax, and
  831. some English to explain that string if necessary.
  832.  
  833.    For full information on the syntax table, see *Note Syntax Tables:
  834. (elisp)Syntax Tables.
  835.  
  836. 
  837. File: emacs,  Node: Init File,  Prev: Syntax,  Up: Customization
  838.  
  839. The Init File, `~/.emacs'
  840. =========================
  841.  
  842.    When Emacs is started, it normally loads a Lisp program from the file
  843. `.emacs' in your home directory.  We call this file your "init file"
  844. because it specifies how to initialize Emacs for you.  You can use the
  845. command line switches `-q' and `-u' to tell Emacs whether to load an
  846. init file, and which one (*note Entering Emacs::.).
  847.  
  848.    There can also be a "default init file", which is the library named
  849. `default.el', found via the standard search path for libraries.  The
  850. Emacs distribution contains no such library; your site may create one
  851. for local customizations.  If this library exists, it is loaded
  852. whenever you start Emacs (except when you specify `-q').  But your init
  853. file, if any, is loaded first; if it sets `inhibit-default-init'
  854. non-`nil', then `default' is not loaded.
  855.  
  856.    Your site may also have a "site startup file"; this is named
  857. `site-start.el', if it exists.  Emacs loads this library before it
  858. loads your init file.  To inhibit loading of this library, use the
  859. option `-no-site-file'.
  860.  
  861.    If you have a large amount of code in your `.emacs' file, you should
  862. move it into another file such as `~/SOMETHING.el', byte-compile it,
  863. and make your `.emacs' file load it with `(load "~/SOMETHING")'.  *Note
  864. Byte Compilation: (elisp)Byte Compilation, for more information about
  865. compiling Emacs Lisp programs.
  866.  
  867. * Menu:
  868.  
  869. * Init Syntax::         Syntax of constants in Emacs Lisp.
  870. * Init Examples::    How to do some things with an init file.
  871. * Terminal Init::    Each terminal type can have an init file.
  872. * Find Init::         How Emacs finds the init file.
  873.  
  874. 
  875. File: emacs,  Node: Init Syntax,  Next: Init Examples,  Up: Init File
  876.  
  877. Init File Syntax
  878. ----------------
  879.  
  880.    The `.emacs' file contains one or more Lisp function call
  881. expressions.  Each of these consists of a function name followed by
  882. arguments, all surrounded by parentheses.  For example, `(setq
  883. fill-column 60)' calls the function `setq' to set the variable
  884. `fill-column' (*note Filling::.) to 60.
  885.  
  886.    The second argument to `setq' is an expression for the new value of
  887. the variable.  This can be a constant, a variable, or a function call
  888. expression.  In `.emacs', constants are used most of the time.  They
  889. can be:
  890.  
  891. Numbers:
  892.      Numbers are written in decimal, with an optional initial minus
  893.      sign.
  894.  
  895. Strings:
  896.      Lisp string syntax is the same as C string syntax with a few extra
  897.      features.  Use a double-quote character to begin and end a string
  898.      constant.
  899.  
  900.      In a string, you can include newlines and special characters
  901.      literally.  But often it is cleaner to use backslash sequences for
  902.      them: `\n' for newline, `\b' for backspace, `\r' for carriage
  903.      return, `\t' for tab, `\f' for formfeed (control-L), `\e' for
  904.      escape, `\\' for a backslash, `\"' for a double-quote, or `\OOO'
  905.      for the character whose octal code is OOO.  Backslash and
  906.      double-quote are the only characters for which backslash sequences
  907.      are mandatory.
  908.  
  909.      `\C-' can be used as a prefix for a control character, as in
  910.      `\C-s' for ASCII control-S, and `\M-' can be used as a prefix for
  911.      a Meta character, as in `\M-a' for `Meta-A' or `\M-\C-a' for
  912.      `Control-Meta-A'.
  913.  
  914. Characters:
  915.      Lisp character constant syntax consists of a `?' followed by
  916.      either a character or an escape sequence starting with `\'.
  917.      Examples: `?x', `?\n', `?\"', `?\)'.  Note that strings and
  918.      characters are not interchangeable in Lisp; some contexts require
  919.      one and some contexts require the other.
  920.  
  921. True:
  922.      `t' stands for `true'.
  923.  
  924. False:
  925.      `nil' stands for `false'.
  926.  
  927. Other Lisp objects:
  928.      Write a single-quote (') followed by the Lisp object you want.
  929.  
  930. 
  931. File: emacs,  Node: Init Examples,  Next: Terminal Init,  Prev: Init Syntax,  Up: Init File
  932.  
  933. Init File Examples
  934. ------------------
  935.  
  936.    Here are some examples of doing certain commonly desired things with
  937. Lisp expressions:
  938.  
  939.    * Make TAB in C mode just insert a tab if point is in the middle of a
  940.      line.
  941.  
  942.           (setq c-tab-always-indent nil)
  943.  
  944.      Here we have a variable whose value is normally `t' for `true' and
  945.      the alternative is `nil' for `false'.
  946.  
  947.    * Make searches case sensitive by default (in all buffers that do not
  948.      override this).
  949.  
  950.           (setq-default case-fold-search nil)
  951.  
  952.      This sets the default value, which is effective in all buffers
  953.      that do not have local values for the variable.  Setting
  954.      `case-fold-search' with `setq' affects only the current buffer's
  955.      local value, which is not what you probably want to do in an init
  956.      file.
  957.  
  958.    * Specify your own email address, if Emacs can't figure it out
  959.      correctly.
  960.  
  961.           (setq user-mail-address "coon@yoyodyne.com")
  962.  
  963.      Various Emacs packages that need your own email address use the
  964.      value of `user-mail-address'.
  965.  
  966.    * Make Text mode the default mode for new buffers.
  967.  
  968.           (setq default-major-mode 'text-mode)
  969.  
  970.      Note that `text-mode' is used because it is the command for
  971.      entering Text mode.  The single-quote before it makes the symbol a
  972.      constant; otherwise, `text-mode' would be treated as a variable
  973.      name.
  974.  
  975.    * Turn on Auto Fill mode automatically in Text mode and related
  976.      modes.
  977.  
  978.           (add-hook 'text-mode-hook
  979.             '(lambda () (auto-fill-mode 1)))
  980.  
  981.      This shows how to add a hook function to a normal hook variable
  982.      (*note Hooks::.).  The function we supply is a list starting with
  983.      `lambda', with a single-quote in front of it to make it a list
  984.      constant rather than an expression.
  985.  
  986.      It's beyond the scope of this manual to explain Lisp functions,
  987.      but for this example it is enough to know that the effect is to
  988.      execute `(auto-fill-mode 1)' when Text mode is entered.  You can
  989.      replace that with any other expression that you like, or with
  990.      several expressions in a row.
  991.  
  992.      Emacs comes with a function named `turn-on-auto-fill' whose
  993.      definition is `(lambda () (auto-fill-mode 1))'.  Thus, a simpler
  994.      way to write the above example is as follows:
  995.  
  996.           (add-hook 'text-mode-hook 'turn-on-auto-fill)
  997.  
  998.    * Load the installed Lisp library named `foo' (actually a file
  999.      `foo.elc' or `foo.el' in a standard Emacs directory).
  1000.  
  1001.           (load "foo")
  1002.  
  1003.      When the argument to `load' is a relative file name, not starting
  1004.      with `/' or `~', `load' searches the directories in `load-path'
  1005.      (*note Lisp Libraries::.).
  1006.  
  1007.    * Load the compiled Lisp file `foo.elc' from your home directory.
  1008.  
  1009.           (load "~/foo.elc")
  1010.  
  1011.      Here an absolute file name is used, so no searching is done.
  1012.  
  1013.    * Rebind the key `C-x l' to run the function `make-symbolic-link'.
  1014.  
  1015.           (global-set-key "\C-xl" 'make-symbolic-link)
  1016.  
  1017.      or
  1018.  
  1019.           (define-key global-map "\C-xl" 'make-symbolic-link)
  1020.  
  1021.      Note once again the single-quote used to refer to the symbol
  1022.      `make-symbolic-link' instead of its value as a variable.
  1023.  
  1024.    * Do the same thing for Lisp mode only.
  1025.  
  1026.           (define-key lisp-mode-map "\C-xl" 'make-symbolic-link)
  1027.  
  1028.    * Redefine all keys which now run `next-line' in Fundamental mode so
  1029.      that they run `forward-line' instead.
  1030.  
  1031.           (substitute-key-definition 'next-line 'forward-line
  1032.                                      global-map)
  1033.  
  1034.    * Make `C-x C-v' undefined.
  1035.  
  1036.           (global-unset-key "\C-x\C-v")
  1037.  
  1038.      One reason to undefine a key is so that you can make it a prefix.
  1039.      Simply defining `C-x C-v ANYTHING' will make `C-x C-v' a prefix,
  1040.      but `C-x C-v' must first be freed of its usual non-prefix
  1041.      definition.
  1042.  
  1043.    * Make `$' have the syntax of punctuation in Text mode.  Note the
  1044.      use of a character constant for `$'.
  1045.  
  1046.           (modify-syntax-entry ?\$ "." text-mode-syntax-table)
  1047.  
  1048.    * Enable the use of the command `eval-expression' without
  1049.      confirmation.
  1050.  
  1051.           (put 'eval-expression 'disabled nil)
  1052.  
  1053. 
  1054. File: emacs,  Node: Terminal Init,  Next: Find Init,  Prev: Init Examples,  Up: Init File
  1055.  
  1056. Terminal-specific Initialization
  1057. --------------------------------
  1058.  
  1059.    Each terminal type can have a Lisp library to be loaded into Emacs
  1060. when it is run on that type of terminal.  For a terminal type named
  1061. TERMTYPE, the library is called `term/TERMTYPE' and it is found by
  1062. searching the directories `load-path' as usual and trying the suffixes
  1063. `.elc' and `.el'.  Normally it appears in the subdirectory `term' of
  1064. the directory where most Emacs libraries are kept.
  1065.  
  1066.    The usual purpose of the terminal-specific library is to map the
  1067. escape sequences used by the terminal's function keys onto more
  1068. meaningful names, using `function-key-map'.  See the file
  1069. `term/lk201.el' for an example of how this is done.  Many function keys
  1070. are mapped automatically according to the information in the Termcap
  1071. data base; the terminal-specific library needs to map only the function
  1072. keys that Termcap does not specify.
  1073.  
  1074.    When the terminal type contains a hyphen, only the part of the name
  1075. before the first hyphen is significant in choosing the library name.
  1076. Thus, terminal types `aaa-48' and `aaa-30-rv' both use the library
  1077. `term/aaa'.  The code in the library can use `(getenv "TERM")' to find
  1078. the full terminal type name.
  1079.  
  1080.    The library's name is constructed by concatenating the value of the
  1081. variable `term-file-prefix' and the terminal type.  Your `.emacs' file
  1082. can prevent the loading of the terminal-specific library by setting
  1083. `term-file-prefix' to `nil'.
  1084.  
  1085.    Emacs runs the hook `term-setup-hook' at the end of initialization,
  1086. after both your `.emacs' file and any terminal-specific library have
  1087. been read in.  Add hook functions to this hook if you wish to override
  1088. part of any of the terminal-specific libraries and to define
  1089. initializations for terminals that do not have a library.  *Note
  1090. Hooks::.
  1091.  
  1092. 
  1093. File: emacs,  Node: Find Init,  Prev: Terminal Init,  Up: Init File
  1094.  
  1095. How Emacs Finds Your Init File
  1096. ------------------------------
  1097.  
  1098.    Normally Emacs uses the environment variable `HOME' to find
  1099. `.emacs'; that's what `~' means in a file name.  But if you have done
  1100. `su', Emacs tries to find your own `.emacs', not that of the user you
  1101. are currently pretending to be.  The idea is that you should get your
  1102. own editor customizations even if you are running as the super user.
  1103.  
  1104.    More precisely, Emacs first determines which user's init file to use.
  1105. It gets the user name from the environment variables `LOGNAME' and
  1106. `USER'; if neither of those exists, it uses effective user-ID.  If that
  1107. user name matches the real user-ID, then Emacs uses `HOME'; otherwise,
  1108. it looks up the home directory corresponding to that user name in the
  1109. system's data base of users.
  1110.  
  1111.